<?php
/* 数据库配置 */
$cfg = [
    'host' => '127.0.0.1',
    'dbname' => 'note_board',
    'user' => 'user',
    'pwd'  => 'userpassword',
    'charset' => 'utf8mb4'
];
/* 创建 PDO 连接 */
try {
    $pdo = new PDO(
        "mysql:host={$cfg['host']};dbname={$cfg['dbname']};charset={$cfg['charset']}",
        $cfg['user'],
        $cfg['pwd'],
        [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
    );
} catch (PDOException $e) {
    exit('数据库连接失败: ' . $e->getMessage());
}
?>